package cn.ld.fj.service.order;

import cn.ld.fj.dao.food.FoodDao;
import cn.ld.fj.dao.order.MealOrderFoodDao;
import cn.ld.fj.entity.Food;
import cn.ld.fj.entity.MealOrder;
import cn.ld.fj.entity.MealOrderFood;
import net.esoar.modules.orm.Page;
import net.esoar.modules.orm.PropertyFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * 安全相关实体的管理类, 包括用户,角色,资源与授权类.
 *
 * @author fly
 */
//Spring Bean的标识.
@Component
//默认将类中的所有函数纳入事务管理.
@Transactional
public class MealOrderFoodManager {

    private static Logger logger = LoggerFactory.getLogger(MealOrderFoodManager.class);
    @Autowired
    private MealOrderFoodDao dao;


    @Transactional(readOnly = true)
    public MealOrderFood getOne(Long id) {
        return dao.get(id);
    }

    public void save(MealOrderFood entity) {
        dao.save(entity);
    }


    public Page<MealOrderFood> getPage(Page<MealOrderFood> page, List<PropertyFilter> filters) {
        return dao.findPage(page, filters);
    }

    public void delete(Long id) {
        dao.delete(id);
    }

    @Transactional(readOnly = true)
    public List<MealOrderFood> findListFood(Long id) {
        return dao.findBy("orderId", id);
    }

    public int batchExecute(String queryString, Object... values){
        return dao.batchExecute(queryString,values);
    }

    public List find(String hql, Map<String, ?> values){
        return dao.find(hql,values);
    }
    public List<MealOrderFood> findBy(String propertyName,Object value){
        return dao.findBy(propertyName,value);
    }
}
